<template>
  <div class="content-wraper">
    <div class="search-box">
      <el-form label-width="100px" :inline="true">
        <el-form-item label="项目名称">
          <el-input v-model="projectName" />
        </el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
        <el-button type="warning" icon="el-icon-refresh" @click="reset()">重置</el-button>
      </el-form>
    </div>
    <div class="detail">
      <com-table :data="dataList" :columns="columns" :total="total" @pageChange="pageChange">
        <template v-slot:psTime="{row: {psTime}}">
          {{ dateFormat(psTime) }}
        </template>
        <template v-slot:status="{row}">
          <a class="com-link" style="text-decoration:underline;" @click="getWorkflowDetail(row)">{{ row.status | formateFlowStatus }}</a>
        </template>
        <template v-slot:createTime="{row: {createTime}}">
          {{ dateFormat(createTime) }}
        </template>

      </com-table>
    </div>
  </div>
</template>

<script>
import { getVirtualAccountList } from '@/api/moneyManage'
import moment from 'moment'
import { getDictName } from '@/utils/comm'
import { workflowStatus } from '@/utils/dicData'
export default {
  name: 'ProjectPurchaseStorehouseInfo',
  components: {
  },
  data() {
    return {
      projectName: '',
      getDictName,
      workflowStatus,
      dataList: [],
      total: 0,
      pageParams: {
        pageNum: 1,
        pageSize: 10
      },
      showModal: false,
      optType: 'add',
      unitDetail: {},
      columns: [
        {
          label: '项目名称',
          prop: 'projectName',
          width: '300'
        },
        {
          label: '合同金额',
          prop: 'contractAmount'
        },
        {
          label: '项目收款金额',
          prop: 'recvAmount'
        },
        {
          label: '银行对内',
          prop: 'bankInternalAmount'
        },
        {
          label: '银行对外',
          prop: 'bankExternalAmount'
        },
        {
          label: '其它资金',
          prop: 'otherAmount'
        },
        {
          label: '账户余额',
          prop: 'balance'
        }
      ]
    }
  },
  mounted() {
    this.getDataList()
  },
  methods: {
    dateFormat(data) {
      if (data) {
        return moment(data).format('YYYY-MM-DD')
      } else {
        return ''
      }
    },
    pageChange(data) {
      this.pageParams = data
      this.getDataList()
    },
    getDataList() {
      const params = {
        ...this.pageParams,
        projectName: this.projectName
      }
      getVirtualAccountList(params).then(res => {
        const { data, total } = res.data || {}
        if (data) {
          this.dataList = data
          this.total = total - 0
        }
      })
    },
    search() {
      this.pageParams.pageNum = 1
      this.getDataList()
    },
    reset() {
      this.projectName = ''
    }

  }
}
</script>

<style lang="scss" scoped>
.search-box {
  height: 50px;
}
.detail{
  height: calc(100% - 50px);
}
</style>
